﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Win8Demo.Helper
{
    public class ParamHelper
    {
        public static string BuildParas(Dictionary<string, object> paras)
        {
            if (paras.Count <= 0 || paras == null)
            {
                return null;
            }
            StringBuilder sb = new StringBuilder();
            foreach (KeyValuePair<string, object> param in paras)
            {
                string key = param.Key;
                object value = param.Value;
                Type type = value.GetType();
                sb.Append(key);
                sb.Append("=");
                if ("String".Equals(type.Name))
                {
                    sb.Append(value);
                }
                else if ("Int32".Equals(type.Name))
                {
                    sb.Append(Convert.ToInt32(value));
                }
                else if ("Int64".Equals(type.Name))
                {
                    sb.Append(Convert.ToInt64(value));
                }
                sb.Append("&");
            }
            return sb.ToString().Substring(0, sb.Length - 1);
        }
    }
}
